﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using TUtils.BasicHelper.Logging;
using TUtils.BasicHelper;
using SharedResources.Tools;

namespace TUtils.LogXImplementor
{
	/// <summary>
	/// This is the dummy implementation of the interface ILogXImplementor.
	/// The assembly "LogXImplementor.dll" represents the software application
	/// specific implementation of all logging tasks. Since a messaging application 
	/// will propably use messages for logging issues, the implementation
	/// of the synchronous logging interface ILogXImplementor is useless.
	/// So we may leave the implementation empty.
	/// </summary>
	public class LogXImplementor : TSingleton<LogXImplementor>, ILogXImplementor
	{
		public bool IsActive(Dictionary<Guid, ILogValue> logValues)
		{
#			if DEBUG
			return true;
#			endif
		}

		public void Write2LogFile(Dictionary<Guid, ILogValue> logValues)
		{
#			if DEBUG
			var line = new StringBuilder();
			foreach (var logValue in logValues.Values.OrderByDescending(lg => lg.Key.IsFilterable))
			{
				line.Append(logValue.Key.ElementName);
				line.Append("=");
				line.Append(logValue.Value);
				line.Append("; ");
			}
			Debug.WriteLine(line);
#			endif
		}
	}
}
